package com.neuedu.JDBCTestWeek05;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Test01 {
    public static void main(String[] args) throws SQLException,ClassNotFoundException {
        //1.加载数据库驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //编写连接数据库的URL地址
        String url="jdbc:mysql://127.0.0.1:3306/demo";
        //2.获取数据的链接
        Connection conn= DriverManager.getConnection(url,"root","root");
        //3.得到一个执行sql的执行器
        Statement stmt=conn.createStatement();
        String sql="insert into users values (null,'赵四','abc','北京')";
        //4.执行sql
        int x=stmt.executeUpdate(sql);
        System.out.println(x);
        //5.关闭(释放)各种资源
        stmt.close();
        conn.close();
    }
}
